const events=require("events");
const EventEmitter=events.EventEmitter;

class Dog extends EventEmitter{
    constructor(dogName,energy){
        super();
        this.dogName=dogName;
        this.energy=energy;
    }
}

let dog=new Dog("tidy",5);
dog.on("bark",()=>{
    console.log("dog is barking")
})